'use strict';
app.controller('modulesAddCtrl',['$scope','$state','modulesAddService','utilService','toaster',function($scope,$state,modulesAddService,utilService,toaster){

    $scope.modulesAddService=modulesAddService;

    //查询栏目
    $scope.findNoPageAll=function(){
        modulesAddService.findNoPageAll($scope).then(function(result){
            switch (result.status){
                case 200:
                    $scope.columns = result.data;
                    break;
                case 661:
                    toaster.pop('waiting', "提示", result.message);
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break
            }
        });
    }

    $scope.findNoPageAll();

    //添加模块
    $scope.addModules=function(){
        modulesAddService.addModules($scope).then(function(result){
            switch (result.status){
                case 200:
                    toaster.pop('success', "提示", "操作成功");
                    $state.go('app.modules');
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break;
            }
        })
    }


}])